<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Class template segment_manager_base</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../boost_interprocess_reference.html#header.boost.interprocess.segment_manager_hpp" title="Header &lt;boost/interprocess/segment_manager.hpp&gt;">
<link rel="prev" href="permissions.html" title="Class permissions">
<link rel="next" href="segment_manager.html" title="Class template segment_manager">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="permissions.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_interprocess_reference.html#header.boost.interprocess.segment_manager_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="segment_manager.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.interprocess.segment_manager_base"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template segment_manager_base</span></h2>
<p>boost::interprocess::segment_manager_base</p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../boost_interprocess_reference.html#header.boost.interprocess.segment_manager_hpp" title="Header &lt;boost/interprocess/segment_manager.hpp&gt;">boost/interprocess/segment_manager.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> MemoryAlgorithm<span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="segment_manager_base.html" title="Class template segment_manager_base">segment_manager_base</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <a class="link" href="segment_manager_base.html" title="Class template segment_manager_base">segment_manager_base</a><span class="special">&lt;</span> <span class="identifier">MemoryAlgorithm</span> <span class="special">&gt;</span> <a name="boost.interprocess.segment_manager_base.segment_manager_base_type"></a><span class="identifier">segment_manager_base_type</span><span class="special">;</span>
  <span class="keyword">typedef</span> <span class="identifier">MemoryAlgorithm</span><span class="special">::</span><span class="identifier">void_pointer</span>           <a name="boost.interprocess.segment_manager_base.void_pointer"></a><span class="identifier">void_pointer</span><span class="special">;</span>             
  <span class="keyword">typedef</span> <span class="identifier">MemoryAlgorithm</span><span class="special">::</span><span class="identifier">mutex_family</span>           <a name="boost.interprocess.segment_manager_base.mutex_family"></a><span class="identifier">mutex_family</span><span class="special">;</span>             
  <span class="keyword">typedef</span> <span class="identifier">MemoryAlgorithm</span>                         <a name="boost.interprocess.segment_manager_base.memory_algorithm"></a><span class="identifier">memory_algorithm</span><span class="special">;</span>         

  <span class="comment">// <a class="link" href="segment_manager_base.html#boost.interprocess.segment_manager_baseconstruct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="segment_manager_base.html#idp56673792-bb"><span class="identifier">segment_manager_base</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">,</span> <span class="identifier">size_type</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="segment_manager_base.html#idp56653920-bb">public member functions</a></span>
  <span class="identifier">size_type</span> <a class="link" href="segment_manager_base.html#idp56654128-bb"><span class="identifier">get_size</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">size_type</span> <a class="link" href="segment_manager_base.html#idp56654832-bb"><span class="identifier">get_free_memory</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">void</span> <span class="special">*</span> <a class="link" href="segment_manager_base.html#idp56655552-bb"><span class="identifier">allocate</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">nothrow_t</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <span class="special">*</span> <a class="link" href="segment_manager_base.html#idp56656976-bb"><span class="identifier">allocate</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <span class="special">*</span> <a class="link" href="segment_manager_base.html#idp56658384-bb"><span class="identifier">allocate_aligned</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">,</span> <span class="identifier">size_type</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">nothrow_t</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <span class="special">*</span> <a class="link" href="segment_manager_base.html#idp56660160-bb"><span class="identifier">allocate_aligned</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">,</span> <span class="identifier">size_type</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> 
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">*</span><span class="special">,</span> <span class="keyword">bool</span> <span class="special">&gt;</span> 
    <a class="link" href="segment_manager_base.html#idp56661968-bb"><span class="identifier">allocation_command</span></a><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">interprocess</span><span class="special">::</span><span class="identifier">allocation_type</span><span class="special">,</span> <span class="identifier">size_type</span><span class="special">,</span> 
                       <span class="identifier">size_type</span><span class="special">,</span> <span class="identifier">size_type</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">T</span> <span class="special">*</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span> <span class="keyword">void</span> <span class="special">*</span><span class="special">,</span> <span class="keyword">bool</span> <span class="special">&gt;</span> 
  <a class="link" href="segment_manager_base.html#idp56664736-bb"><span class="identifier">raw_allocation_command</span></a><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">interprocess</span><span class="special">::</span><span class="identifier">allocation_type</span><span class="special">,</span> <span class="identifier">size_type</span><span class="special">,</span> 
                         <span class="identifier">size_type</span><span class="special">,</span> <span class="identifier">size_type</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">void</span> <span class="special">*</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">size_type</span> <span class="special">=</span> <span class="number">1</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="segment_manager_base.html#idp56667600-bb"><span class="identifier">deallocate</span></a><span class="special">(</span><span class="keyword">void</span> <span class="special">*</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="segment_manager_base.html#idp56668672-bb"><span class="identifier">grow</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="segment_manager_base.html#idp56669776-bb"><span class="identifier">shrink_to_fit</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="segment_manager_base.html#idp56670528-bb"><span class="identifier">all_memory_deallocated</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="segment_manager_base.html#idp56671296-bb"><span class="identifier">check_sanity</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="segment_manager_base.html#idp56672032-bb"><span class="identifier">zero_free_memory</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">size_type</span> <a class="link" href="segment_manager_base.html#idp56672784-bb"><span class="identifier">size</span></a><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span> <span class="special">*</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="segment_manager_base.html#idp56675728-bb">public static functions</a></span>
  <span class="keyword">static</span> <span class="identifier">size_type</span> <a class="link" href="segment_manager_base.html#idp56675936-bb"><span class="identifier">get_min_size</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="segment_manager_base.html#boost.interprocess.segment_manager_basepublic-data-members">public data members</a></span>
  <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">size_type</span> <a class="link" href="segment_manager_base.html#boost.interprocess.segment_manager_base.PayloadPerAllocation"><span class="identifier">PayloadPerAllocation</span></a><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idp76359776"></a><h2>Description</h2>
<p>This object is the public base class of segment manager. This class only depends on the memory allocation algorithm and implements all the allocation features not related to named or unique objects.</p>
<p>Storing a reference to <a class="link" href="segment_manager.html" title="Class template segment_manager">segment_manager</a> forces the holder class to be dependent on index types and character types. When such dependence is not desirable and only anonymous and raw allocations are needed, <a class="link" href="segment_manager_base.html" title="Class template segment_manager_base">segment_manager_base</a> is the correct answer. </p>
<div class="refsect2">
<a name="idp76361680"></a><h3>
<a name="boost.interprocess.segment_manager_baseconstruct-copy-destruct"></a><code class="computeroutput">segment_manager_base</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><a name="idp56673792-bb"></a><span class="identifier">segment_manager_base</span><span class="special">(</span><span class="identifier">size_type</span> sz<span class="special">,</span> <span class="identifier">size_type</span> reserved_bytes<span class="special">)</span><span class="special">;</span></pre>
<p>Constructor of the <code class="computeroutput"><a class="link" href="segment_manager_base.html" title="Class template segment_manager_base">segment_manager_base</a></code></p>
<p>"size" is the size of the memory segment where the basic segment manager is being constructed.</p>
<p>"reserved_bytes" is the number of bytes after the end of the memory algorithm object itself that the memory algorithm will exclude from dynamic allocation</p>
<p>Can throw </p>
</li></ol></div>
</div>
<div class="refsect2">
<a name="idp76367072"></a><h3>
<a name="idp56653920-bb"></a><code class="computeroutput">segment_manager_base</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="identifier">size_type</span> <a name="idp56654128-bb"></a><span class="identifier">get_size</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Returns the size of the memory segment </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">size_type</span> <a name="idp56654832-bb"></a><span class="identifier">get_free_memory</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Returns the number of free bytes of the memory segment </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <span class="special">*</span> <a name="idp56655552-bb"></a><span class="identifier">allocate</span><span class="special">(</span><span class="identifier">size_type</span> nbytes<span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">nothrow_t</span><span class="special">)</span><span class="special">;</span></pre>
<p>Allocates nbytes bytes. This function is only used in single-segment management. Never throws </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <span class="special">*</span> <a name="idp56656976-bb"></a><span class="identifier">allocate</span><span class="special">(</span><span class="identifier">size_type</span> nbytes<span class="special">)</span><span class="special">;</span></pre>
<p>Allocates nbytes bytes. Throws <code class="computeroutput"><a class="link" href="bad_alloc.html" title="Class bad_alloc">boost::interprocess::bad_alloc</a></code> on failure </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <span class="special">*</span> <a name="idp56658384-bb"></a><span class="identifier">allocate_aligned</span><span class="special">(</span><span class="identifier">size_type</span> nbytes<span class="special">,</span> <span class="identifier">size_type</span> alignment<span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">nothrow_t</span><span class="special">)</span><span class="special">;</span></pre>
<p>Allocates nbytes bytes. This function is only used in single-segment management. Never throws </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <span class="special">*</span> <a name="idp56660160-bb"></a><span class="identifier">allocate_aligned</span><span class="special">(</span><span class="identifier">size_type</span> nbytes<span class="special">,</span> <span class="identifier">size_type</span> alignment<span class="special">)</span><span class="special">;</span></pre>
<p>Allocates nbytes bytes. This function is only used in single-segment management. Throws <code class="computeroutput"><a class="link" href="bad_alloc.html" title="Class bad_alloc">bad_alloc</a></code> when fails </p>
</li>
<li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> 
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">*</span><span class="special">,</span> <span class="keyword">bool</span> <span class="special">&gt;</span> 
  <a name="idp56661968-bb"></a><span class="identifier">allocation_command</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">interprocess</span><span class="special">::</span><span class="identifier">allocation_type</span> command<span class="special">,</span> 
                     <span class="identifier">size_type</span> limit_size<span class="special">,</span> <span class="identifier">size_type</span> preferred_size<span class="special">,</span> 
                     <span class="identifier">size_type</span> <span class="special">&amp;</span> received_size<span class="special">,</span> <span class="identifier">T</span> <span class="special">*</span> reuse_ptr <span class="special">=</span> <span class="number">0</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span> <span class="keyword">void</span> <span class="special">*</span><span class="special">,</span> <span class="keyword">bool</span> <span class="special">&gt;</span> 
<a name="idp56664736-bb"></a><span class="identifier">raw_allocation_command</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">interprocess</span><span class="special">::</span><span class="identifier">allocation_type</span> command<span class="special">,</span> 
                       <span class="identifier">size_type</span> limit_objects<span class="special">,</span> <span class="identifier">size_type</span> preferred_objects<span class="special">,</span> 
                       <span class="identifier">size_type</span> <span class="special">&amp;</span> received_objects<span class="special">,</span> <span class="keyword">void</span> <span class="special">*</span> reuse_ptr <span class="special">=</span> <span class="number">0</span><span class="special">,</span> 
                       <span class="identifier">size_type</span> sizeof_object <span class="special">=</span> <span class="number">1</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idp56667600-bb"></a><span class="identifier">deallocate</span><span class="special">(</span><span class="keyword">void</span> <span class="special">*</span> addr<span class="special">)</span><span class="special">;</span></pre>
<p>Deallocates the bytes allocated with allocate/allocate_many() pointed by addr </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idp56668672-bb"></a><span class="identifier">grow</span><span class="special">(</span><span class="identifier">size_type</span> extra_size<span class="special">)</span><span class="special">;</span></pre>
<p>Increases managed memory in extra_size bytes more. This only works with single-segment management. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idp56669776-bb"></a><span class="identifier">shrink_to_fit</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>Decreases managed memory to the minimum. This only works with single-segment management. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> <a name="idp56670528-bb"></a><span class="identifier">all_memory_deallocated</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>Returns the result of "all_memory_deallocated()" function of the used memory algorithm </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> <a name="idp56671296-bb"></a><span class="identifier">check_sanity</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>Returns the result of "check_sanity()" function of the used memory algorithm </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idp56672032-bb"></a><span class="identifier">zero_free_memory</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>Writes to zero free memory (memory not yet allocated) of the memory algorithm </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">size_type</span> <a name="idp56672784-bb"></a><span class="identifier">size</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span> <span class="special">*</span> ptr<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Returns the size of the buffer previously allocated pointed by ptr. </li>
</ol></div>
</div>
<div class="refsect2">
<a name="idp76430400"></a><h3>
<a name="idp56675728-bb"></a><code class="computeroutput">segment_manager_base</code> public static functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><span class="keyword">static</span> <span class="identifier">size_type</span> <a name="idp56675936-bb"></a><span class="identifier">get_min_size</span><span class="special">(</span><span class="identifier">size_type</span> size<span class="special">)</span><span class="special">;</span></pre>
<p>Obtains the minimum size needed by the segment manager </p>
</li></ol></div>
</div>
<div class="refsect2">
<a name="idp76434448"></a><h3>
<a name="boost.interprocess.segment_manager_basepublic-data-members"></a><code class="computeroutput">segment_manager_base</code> 
        public
       public data members</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">size_type</span> <a name="boost.interprocess.segment_manager_base.PayloadPerAllocation"></a><span class="identifier">PayloadPerAllocation</span><span class="special">;</span></pre>
<p>This constant indicates the payload size associated with each allocation of the memory algorithm </p>
</li></ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2005-2012 Ion Gaztanaga<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="permissions.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_interprocess_reference.html#header.boost.interprocess.segment_manager_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="segment_manager.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
